package com.wangxc.rabbitmq.controller;

import com.wangxc.rabbitmq.producter.MessageSender;
import com.wangxc.rabbitmq.producter.MessageSender2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/rabbit")
public class RabbitTestController {

    @Autowired
    private MessageSender messageSender;
    @Autowired
    private MessageSender2 messageSender2;

    @RequestMapping("/hello")
    public String hello(String message){
        messageSender.send(message);
        return "SUCCESS";
    }

    @RequestMapping("/oneToMany")
    public String oneToMany(String message){
        for (int i = 0; i < 9; i++) {
            messageSender.send(message);
        }
        return "SUCCESS";
    }

    @RequestMapping("/manyToMany")
    public String manyToMany(String message){
        for (int i = 0; i < 9; i++) {
            messageSender.send(message);
            messageSender2.send(message);
        }
        return "SUCCESS";
    }
}
